<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

  if (tep_not_null($action)) {
    switch ($action) {
      case 'setflag':
        if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
          if (isset($HTTP_GET_VARS['pID'])) {
            tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);
          }

          if (USE_CACHE == 'true') {
            tep_reset_cache_block('categories');
            tep_reset_cache_block('also_purchased');
          }
        }

        tep_redirect(tep_href_link(FILENAME_NEWSCENTER, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));
        break;
      case 'delete_news_confirm':
        if (isset($HTTP_POST_VARS['newscenter_id'])) {
          $newscenter_id = tep_db_prepare_input($HTTP_POST_VARS['newscenter_id']);

          tep_db_query("delete from " . TABLE_NEWSCENTER_DESCRIPTION . " where newscenter_id = '" . (int)$newscenter_id . "'");
		  //delete images
		  $images_query = tep_db_query("select image from " . TABLE_NEWSCENTER_IMAGES . " where newscenter_id = " . (int)$newscenter_id);
		  $image_path = DIR_FS_CATALOG_IMAGES . 'newscenter/';
		  while($images = tep_db_fetch_array($images_query)) {
			  if(file_exists($image_path . $images['image'])) @unlink($image_path . $images['image']);
		  }
		  tep_db_query("delete from " . TABLE_NEWSCENTER_IMAGES . " where newscenter_id = '" . (int)$newscenter_id . "'");
		  
		  tep_db_query("delete from " . TABLE_NEWSCENTER . " where newscenter_id = '" . (int)$newscenter_id . "'");
        }

        /*if (USE_CACHE == 'true') {
          tep_reset_cache_block('categories');
          tep_reset_cache_block('also_purchased');
        }*/

        tep_redirect(tep_href_link(FILENAME_NEWSCENTER));
        break;
      case 'insert_news':
      case 'update_news':
        if (isset($HTTP_GET_VARS['nID'])) $newscenter_id = tep_db_prepare_input($HTTP_GET_VARS['nID']);

        //$sql_data_array = array('products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']));
		$sql_data_array = array('default_image_id' => tep_db_prepare_input($HTTP_POST_VARS['default_image_id']));

        if ($action == 'insert_news') {
          $insert_sql_data = array('date_added' => 'now()');

          $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

          tep_db_perform(TABLE_NEWSCENTER, $sql_data_array);
          $newscenter_id = tep_db_insert_id();
		  tep_db_query("update " . TABLE_NEWSCENTER_IMAGES . " set newscenter_id = " . $newscenter_id . " where newscenter_id = " . (-1) * $admin['id']);
        } elseif ($action == 'update_news') {
          $update_sql_data = array('last_modified' => 'now()');

          $sql_data_array = array_merge($sql_data_array, $update_sql_data);

          tep_db_perform(TABLE_NEWSCENTER, $sql_data_array, 'update', "newscenter_id = '" . (int)$newscenter_id . "'");
        }

        $languages = tep_get_languages();
        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
          $language_id = $languages[$i]['id'];

          $sql_data_array = array('newscenter_title' => tep_db_prepare_input($HTTP_POST_VARS['newscenter_title'][$language_id]),
                                  'newscenter_description' => tep_db_prepare_input($HTTP_POST_VARS['newscenter_description'][$language_id]));

          if ($action == 'insert_news') {
            $insert_sql_data = array('newscenter_id' => $newscenter_id,
                                     'language_id' => $language_id);

            $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

            tep_db_perform(TABLE_NEWSCENTER_DESCRIPTION, $sql_data_array);
          } elseif ($action == 'update_news') {
            tep_db_perform(TABLE_NEWSCENTER_DESCRIPTION, $sql_data_array, 'update', "newscenter_id = '" . (int)$newscenter_id . "' and language_id = '" . (int)$language_id . "'");
          }
        }

        /*if (USE_CACHE == 'true') {
          tep_reset_cache_block('categories');
          tep_reset_cache_block('also_purchased');
        }*/

        tep_redirect(tep_href_link(FILENAME_NEWSCENTER, 'nID=' . $newscenter_id));
        break;
    }
  }

// check if the catalog image directory exists
  if (is_dir(DIR_FS_CATALOG_IMAGES)) {
    if (!tep_is_writable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
  } else {
    $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
  }

  require(DIR_WS_INCLUDES . 'template_top.php');

  if ($action == 'add_news') {
    $parameters = array('newscenter_id' => '',
                       'newscenter_title' => '',
					   'newscenter_description' => '',
					   'newscenter_images' => array());

    $nInfo = new objectInfo($parameters);

    if (isset($HTTP_GET_VARS['nID']) && empty($HTTP_POST_VARS)) {
	  $newscenter_query = tep_db_query("select n.newscenter_id, n.date_added, nd.newscenter_title, nd.newscenter_description from " . TABLE_NEWSCENTER . " n, " . TABLE_NEWSCENTER_DESCRIPTION . " nd where n.newscenter_id = '" . (int)$HTTP_GET_VARS['nID'] . "' and n.newscenter_id = nd.newscenter_id and nd.language_id = '" . (int)$languages_id . "'");
      $newscenter = tep_db_fetch_array($newscenter_query);

      $nInfo->objectInfo($newscenter);

      $newscenter_images_query = tep_db_query("select id, image from " . TABLE_NEWSCENTER_IMAGES . " where newscenter_id = '" . (int)$newscenter['newscenter_id'] . "'");
      while ($newscenter_images = tep_db_fetch_array($newscenter_images_query)) {
        $nInfo->newscenter_images[] = array('id' => $newscenter_images['id'],
                                            'image' => $newscenter_images['image']);
      }
    }

    $languages = tep_get_languages();

    /*if (!isset($pInfo->products_status)) $pInfo->products_status = '1';
    switch ($pInfo->products_status) {
      case '0': $in_status = false; $out_status = true; break;
      case '1':
      default: $in_status = true; $out_status = false;
    }*/

    $form_action = (isset($HTTP_GET_VARS['nID'])) ? 'update_news' : 'insert_news';
?>
<link rel="stylesheet" type="text/css" href="<?php echo tep_catalog_href_link('ext/jquery/jHtmlArea/jHtmlArea.css'); ?>">
<style>
table.imageContent {border-collapse:collapse; text-align:center; margin-bottom:20px}
table.imageContent, table.imageContent td {border:1px solid #CCC}
span.imageUploadTitle {display:inline-block; width:128px}
</style>
<script type="text/javascript" src="<?php echo tep_catalog_href_link('ext/jquery/jHtmlArea/jHtmlArea-0.7.0.js'); ?>"></script>
<script type="text/javascript" src="<?php echo tep_catalog_href_link('ext/jquery/ajaxfileupload.js'); ?>"></script>
<script>
$(function() {
	$("textarea").htmlarea(); // Initialize all TextArea's as jHtmlArea's with default values
	$('.jHtmlArea').css('width', '704px'); // Require for outer frame's width
	$('.jHtmlArea').find('iframe').css('width', '700px'); // Should allow for padding based on CSS rules
});
function ajaxFileUpload() {
	$("#loading").ajaxStart(function() {
		$(this).show();
	}).ajaxComplete(function() {
		$(this).hide();
	});

	$.ajaxFileUpload({
		url:'<?php echo FILENAME_NEWSCENTER_IMAGES . '?action=upload_image' . (isset($HTTP_GET_VARS['nID']) && !empty($HTTP_GET_VARS['nID']) ? '&nID=' . $HTTP_GET_VARS['nID'] : ''); ?>',
		secureuri:false,
		fileElementId:'fileToUpload',
		dataType: 'json',
		data:{name:'logan', id:'id'},
		success: function (data, status) {
			$('#imageContent').html(data);
		},
		error: function (data, status, e) {
			alert(e);
		}
	})
	return false;
};
function ajaxFileDel(id) {
	if(confirm('<?php echo TEXT_DELETE_IMAGE_INTRO; ?>')) {
		$("#loading").show();
		$.get('<?php echo FILENAME_NEWSCENTER_IMAGES . '?action=delete_image' . (isset($HTTP_GET_VARS['nID']) && !empty($HTTP_GET_VARS['nID']) ? '&nID=' . $HTTP_GET_VARS['nID'] : '') . '&mID='; ?>' + id, function(data) {
			$('#imageContent').html(data);
			$("#loading").hide();
		});
	}
	return false;
};
</script>
<?php echo tep_draw_form('add_news', FILENAME_NEWSCENTER, (isset($HTTP_GET_VARS['nID']) ? 'nID=' . $HTTP_GET_VARS['nID'] : '') . '&action=' . $form_action, 'post'); ?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo TEXT_ADD_NEWS; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td><div id="imageContent"><?php include(FILENAME_NEWSCENTER_IMAGES); ?></div>
        	<div><span class="imageUploadTitle"><?=TEXT_UPLOAD_IMAGE; ?></span>
            	 <input id="fileToUpload" type="file" size="45" name="fileToUpload" class="input">&nbsp;
    			 <button class="button" id="buttonUpload" onClick="return ajaxFileUpload();">Upload</button>
                 <img id="loading" src="../ext/jquery/loading.gif" style="display:none;"></div><hr />
    	</td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" cellspacing="0" cellpadding="2">
<?php
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
          <tr>
            <td class="main" width="100px"><?php if ($i == 0) echo TEXT_TITLE; ?></td>
            <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('newscenter_title[' . $languages[$i]['id'] . ']', (isset($nInfo) && is_object($nInfo) ? tep_get_newscenter_title($nInfo->newscenter_id, $languages[$i]['id']) : ''), 'size="60px"'); ?></td>
          </tr>
<?php
    }
?>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>
          <tr>
          	<td colspan="2">
            	&lt;img src="images/.." style=" text-align:right; margin:10px 10px 10px 0; float:left;"&frasl;&gt;text text ...<br /><br />
                &lt;img src="images/.." style=" text-align:left; margin:10px 0px 10px 10px; float:right;"&frasl;&gt;text text ...<br /><br />
            </td>
          </tr>
<?php
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
          <tr>
            <td class="main" valign="top"><?php if ($i == 0) echo TEXT_DESCRIPTION; ?></td>
            <td><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
                <td class="main"><?php echo tep_draw_textarea_field('newscenter_description[' . $languages[$i]['id'] . ']', 'soft', '112', '15', (isset($nInfo) ? tep_get_newscenter_description($nInfo->newscenter_id, $languages[$i]['id']) : '')); ?><br /></td>
              </tr>
            </table></td>
          </tr>
<?php
    }
?>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td class="smallText" align="right"><?php echo tep_draw_hidden_field('date_added', (tep_not_null($nInfo->date_added) ? $nInfo->date_added : date('Y-m-d'))) . tep_draw_button(IMAGE_SAVE, 'disk', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_NEWSCENTER, (isset($HTTP_GET_VARS['nID']) ? 'nID=' . $HTTP_GET_VARS['nID'] : ''))); ?></td>
      </tr>
    </table>

<!--<script type="text/javascript">
$('#products_date_available').datepicker({
  dateFormat: 'yy-mm-dd'
});
</script>-->

    </form>
<?php
  } elseif ($action == 'new_product_preview') {
    $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_price_wholesale, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");
    $product = tep_db_fetch_array($product_query);

    $pInfo = new objectInfo($product);
    $products_image_name = $pInfo->products_image;

    $languages = tep_get_languages();
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
      $pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']);
      $pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']);
      $pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']);
?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . $pInfo->products_name; ?></td>
            <td class="pageHeading" align="right"><?php echo TEXT_PREVIEW_RETAIL . $currencies->format($pInfo->products_price) . '&nbsp;|&nbsp;' . TEXT_PREVIEW_WHOLESALE . $currencies->format($pInfo->products_price_wholesale); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td class="main"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $pInfo->products_description; ?></td>
      </tr>
<?php
      if ($pInfo->products_url) {
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td class="main"><?php echo sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_url); ?></td>
      </tr>
<?php
      }
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
<?php
      if ($pInfo->products_date_available > date('Y-m-d')) {
?>
      <tr>
        <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_AVAILABLE, tep_date_long($pInfo->products_date_available)); ?></td>
      </tr>
<?php
      } else {
?>
      <tr>
        <td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_ADDED, tep_date_long($pInfo->products_date_added)); ?></td>
      </tr>
<?php
      }
?>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
<?php
    }

    if (isset($HTTP_GET_VARS['origin'])) {
      $pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0);
      if ($pos_params != false) {
        $back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params);
        $back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1);
      } else {
        $back_url = $HTTP_GET_VARS['origin'];
        $back_url_params = '';
      }
    } else {
      $back_url = FILENAME_NEWSCENTER;
      $back_url_params = 'cPath=' . $cPath . '&pID=' . $pInfo->products_id;
    }
?>
      <tr>
        <td align="right" class="smallText"><?php echo tep_draw_button(IMAGE_BACK, 'triangle-1-w', tep_href_link($back_url, $back_url_params, 'NONSSL')); ?></td>
      </tr>
    </table>
<?php
  } else {
?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
            <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <td class="smallText" align="right">
<?php
    echo tep_draw_form('search', FILENAME_NEWSCENTER, '', 'get');
    echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search');
    echo tep_hide_session_id() . '</form>';
?>
                </td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr class="dataTableHeadingRow">
                <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_TITLE; ?></td>
                <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
                <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
              </tr>
<?php
    $newscenter_count = 0;
    $rows = 0;
    if (isset($HTTP_GET_VARS['search'])) {
      $search = tep_db_prepare_input($HTTP_GET_VARS['search']);

	  $newscenter_query = tep_db_query("select n.newscenter_id, n.date_added, n.last_modified, nd.newscenter_title from " . TABLE_NEWSCENTER . " n, " . TABLE_NEWSCENTER_DESCRIPTION . " nd where n.newscenter_id = nd.newscenter_id and nd.language_id = '" . (int)$languages_id . "' and nd.newscenter_title like '%" . tep_db_input($search) . "%' order by n.newscenter_id desc");
    } else {
	  $newscenter_query = tep_db_query("select n.newscenter_id, n.date_added, n.last_modified, nd.newscenter_title from " . TABLE_NEWSCENTER . " n, " . TABLE_NEWSCENTER_DESCRIPTION . " nd where n.newscenter_id = nd.newscenter_id and nd.language_id = '" . (int)$languages_id . "' order by n.newscenter_id desc");
    }
    while ($newscenter = tep_db_fetch_array($newscenter_query)) {
      $newscenter_count++;
      $rows++;
	  
	  if ( (!isset($HTTP_GET_VARS['nID']) || (isset($HTTP_GET_VARS['nID']) && ($HTTP_GET_VARS['nID'] == $newscenter['newscenter_id']))) && !isset($nInfo) && !isset($nInfo) && (substr($action, 0, 3) != 'new')) {
        $nInfo = new objectInfo($newscenter);
      }

      if (isset($nInfo) && is_object($nInfo) && $newscenter['newscenter_id'] == $HTTP_GET_VARS['nID']) {
        echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWSCENTER, 'nID=' . $newscenter['newscenter_id']) . '\'">' . "\n";
      } else {
        echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWSCENTER, 'nID=' . $newscenter['newscenter_id']) . '\'">' . "\n";
      }
?>
                <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_NEWSCENTER, 'nID=' . $newscenter['newscenter_id']) . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a>&nbsp;<strong>' . $newscenter['newscenter_title'] . '</strong>'; ?></td>
                <td class="dataTableContent" align="center">&nbsp;</td>
                <td class="dataTableContent" align="right"><?php if ($newscenter['newscenter_id'] == $HTTP_GET_VARS['nID']) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_NEWSCENTER, 'nID=' . $newscenter['newscenter_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
              </tr>
<?php
    }
?>
              <tr>
                <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
                  <tr>
                    <td class="smallText"><?php echo TEXT_NEWS . '&nbsp;' . $newscenter_count; ?></td>
                    <td align="right" class="smallText"><?php if (!isset($HTTP_GET_VARS['search'])) echo tep_draw_button(IMAGE_ADD_NEWS, 'plus', tep_href_link(FILENAME_NEWSCENTER, 'action=add_news')); ?>&nbsp;</td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
<?php
    $heading = array();
    $contents = array();
    switch ($action) {
      case 'delete_news':
        $heading[] = array('text' => '<strong>' . TEXT_INFO_HEADING_DELETE_NEWS . '</strong>');

        $contents = array('form' => tep_draw_form('news', FILENAME_NEWSCENTER, 'action=delete_news_confirm') . tep_draw_hidden_field('newscenter_id', $nInfo->newscenter_id));
        $contents[] = array('text' => TEXT_DELETE_NEWS_INTRO);
        $contents[] = array('text' => '<br /><strong>' . $nInfo->newscenter_title . '</strong>');

        $contents[] = array('align' => 'center', 'text' => '<br />' . tep_draw_button(IMAGE_DELETE, 'trash', null, 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_NEWSCENTER, 'nID=' . $nInfo->newscenter_id)));
        break;
      default:
        if ($rows > 0) {
          if (isset($nInfo) && is_object($nInfo)) {
            $heading[] = array('text' => '<strong>' . $nInfo->newscenter_title . '</strong>');

            $contents[] = array('align' => 'center', 'text' => tep_draw_button(IMAGE_EDIT, 'document', tep_href_link(FILENAME_NEWSCENTER, 'nID=' . $nInfo->newscenter_id . '&action=add_news')) . tep_draw_button(IMAGE_DELETE, 'trash', tep_href_link(FILENAME_NEWSCENTER, 'nID=' . $nInfo->newscenter_id . '&action=delete_news')));
            $contents[] = array('text' => '<br />' . TEXT_DATE_ADDED . ' ' . tep_date_short($nInfo->date_added));
            if (tep_not_null($nInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($nInfo->last_modified));
            //$contents[] = array('text' => '<br />' . tep_info_image($cInfo->categories_image, $cInfo->categories_name, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT) . '<br />' . $cInfo->categories_image);
          }
        } else { // create news
          $heading[] = array('text' => '<strong>' . EMPTY_NEWS . '</strong>');

          $contents[] = array('text' => TEXT_NO_NEWS);
        }
        break;
    }

    if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
      echo '            <td width="25%" valign="top">' . "\n";

      $box = new box;
      echo $box->infoBox($heading, $contents);

      echo '            </td>' . "\n";
    }
?>
          </tr>
        </table></td>
      </tr>
    </table>
<?php
  }

  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
